<?php
require_once 'constants.php';
require_once 'db.php';

$id = $_GET['img_id'];
$row = dbGetImageById($id);
$img = imagecreatefromstring($row['image']);
$img = imagerotate($img, 90, 0);

//Capure image as a BIN variable
ob_start();
imagejpeg($img);
$imgBin = ob_get_contents();
ob_end_clean();
dbUpdateImageById($id, addslashes($imgBin));

header('content-type: image/jpg');
imagejpeg($img);
?>
